package com.jiyun.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiyun.mapper.IntegrateMapper;
import com.jiyun.pojo.Integrate;
import com.jiyun.service.IntegrateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author: 刘清芳
 * @description: impl
 * @date: 2024/1/3 20:35
 */
@Service
public class IntegrateServiceImpl extends ServiceImpl<IntegrateMapper, Integrate>implements IntegrateService {
    @Autowired
    IntegrateMapper integralMapper;

    @Override
    public IPage<Integrate> findAll(Integer pageNum, Integer pageSize, Integrate integrate) {
        IPage<Integrate> page = new Page<>();
        // 创建一个分页对象
        LambdaQueryWrapper<Integrate> wrapper = new LambdaQueryWrapper<>();
//        查询状态上下架  0 开启 1 下架
        if (integrate.getSjstatus()!= null) {
            wrapper.eq(Integrate::getSjstatus, integrate.getSjstatus());
        }

        // 创建一个LambdaQueryWrapper对象，用于查询封装
        page.setCurrent(pageNum);  // 设置当前页码
        page.setSize(pageSize);  // 设置每页显示的记录数
        return baseMapper.selectPage(page, wrapper);   //  调用baseMapper的selectPage方法进行分页查询，并返回结果
    }

//    添加
    @Override
    public void findAdd(Integrate integrate) {
        this.baseMapper.insert(integrate);
    }

}
